import {BaseDTO} from './BaseDTO';
import {message} from 'antd';
declare let GLOBAL:any;

export const base: BaseDTO = {
    baseApiUrl: '/api',
    _csrf: 'd25597b5-9c54-49e0-8580-c855eebde0ea',
    loginApi: ''
};

export const assign = function (target, varArgs) {
    if (target == null) {
        throw new TypeError('Cannot convert undefined or null to object');
    }
    let to = Object(target);
    for (let index = 1; index < arguments.length; index++) {
        let nextSource = arguments[index];
        if (nextSource != null) {
            for (let nextKey in nextSource) {
                if (Object.prototype.hasOwnProperty.call(nextSource, nextKey)) {
                    to[nextKey] = nextSource[nextKey];
                }
            }
        }
    }
    return to;
};

export const redirect = function(XMLHttpRequest){
    if(!!XMLHttpRequest && (XMLHttpRequest.getResponseHeader("loginStatus") == "accessDenied")){
        message.info("登录超时",3);
        window.setTimeout(function(){
            window.location.href = GLOBAL.loginUrl;
        },1000);
    }
}